#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Last Update:

'''docstring
'''

__revision__ = '0.1'
__author__ = 'lxd'
import threading
import sys

class ThreadWithQuit(threading.Thread):
    def __init__(self,log, **kwargs):
        threading.Thread.__init__(self)
        self.timeToQuit = threading.Event()
        self.timeToQuit.clear()
        self.log = log
        
    def stop(self):
        self.timeToQuit.set()

    def checkSet(self):
        """随时停止信号量。
        在循环里或等待网络返回等耗时的工作前使用
        """
        if self.timeToQuit.isSet():
            self.log.debug('thread exit')
            sys.exit()




